/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 * @author VICKY
 */
public class ComunicacionBD {
      public String db = "alumno";
    public String url = "jdbc:mysql://localhost/"+db;
    public String user = "root";
    public String pass = "root";

    public ComunicacionBD()
    {
        
    }

    public Connection Conectar()
    {
        Connection link = null;
        try
        {
            //Cargamos el Driver MySQL
            Class.forName("com.mysql.jdbc.Driver");
            //Creamos un enlace hacia la base de datos
            link = DriverManager.getConnection(this.url, this.user, this.pass);
        }
        catch (Exception e)
        {
            System.out.println( "No se pudo conectar a la base de datos: "+e);
        }
        return link;  
    }  
}
